package com.huaxindata.im.util;

import android.content.Context;
import android.content.SharedPreferences;

/**
 * Created by Administrator on 2017/9/4.
 *
 */

public class SharePreferenceUtil {
    private static final String NAME="ImSetting";
    public static int getInt(Context context,String key,int defValue){
        SharedPreferences preferences = context.getSharedPreferences(NAME, context.MODE_PRIVATE);
        return preferences.getInt(key, defValue);
    }
    public static void setInt(Context context,String key,int value){
        SharedPreferences preferences = context.getSharedPreferences(NAME, context.MODE_PRIVATE);
        SharedPreferences.Editor editor = preferences.edit();
        editor.putInt(key, value);
        editor.commit();
    }
    public static void setBoolean(Context context,String key,boolean value){
        SharedPreferences preferences = context.getSharedPreferences(NAME, context.MODE_PRIVATE);
        SharedPreferences.Editor editor = preferences.edit();
        editor.putBoolean(key, value);
        editor.commit();
    }
    public static boolean getBoolean(Context context,String key,boolean defValue){
        SharedPreferences preferences = context.getSharedPreferences(NAME, context.MODE_PRIVATE);
        return preferences.getBoolean(key, defValue);
    }
}
